package javaDemo07;

import java.io.*;

public class scannerFile {
    public static void main(String[] args) throws IOException {
//        File src = new File("D:\\测试文件夹");
//        File descFile = new File("C:\\");
//        copyFoleder(src,descFile);
        BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));


        System.out.println("请输入一个字符串");
        String line = bfr.readLine();
        System.out.println("你输入的字符串是： " + line);



        bfr.close();
    }








    public static void copyFoleder(File a,File b)throws IOException{
        if(a.isDirectory()){
            String aname = a.getName();
            File newFolder = new File(b,aname);
            if(!newFolder.exists()){
                newFolder.mkdir();
            }
            File[] fileArray = a.listFiles();
            for(File f:fileArray){
                copyFoleder(f,newFolder);
            }
        }else{
            File newFolder = new File(b,a.getName());
            copyFiles(a,newFolder);
        }
    }
    public static void copyFiles(File a,File b)throws IOException{
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(a));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(b));

        byte[] bytes = new byte[1024];
        int len;
        while((len = bis.read(bytes)) != -1){
            bos.write(bytes,0,len);
        }

        bis.close();
        bos.close();

    }
}
